<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <c:set var="ctx" value="${pageContext.request.contextPath }"></c:set>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<title>华阳物流</title>
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/bootstrap.min.css"/>
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/singin.css"/>
	</head>
	<body class="text-center">
		<div class="login-wrap">
		<form action="${ctx }/back/userLogin" method="post" class="form-signin pt-5" onsubmit="return test()">
			<div class="text-left form-title-info ">
				<img class="mb-4 form-title" src="<%=request.getContextPath()%>/resources/img/login-title.png" alt="">
			</div>
           
           <!--<h1 class="h3 mb-3 font-weight-normal">Please sign in</h1>-->
           <div class="form-group row">
               <label for="user" class="col-sm-3 col-form-label d-md-block">账号：</label>
               <div class="col-sm-9 text-left">
                    <span class="glyphicon glyphicon-user"></span><!--input的 required="" 属性与onsubmit="return test()"冲突-->
                    <input id="username" name="username" id="user" class="form-control" placeholder=""  autofocus="" type="text">
               </div>              
           </div>
           <div class="form-group row">
           	   <label for="inputPassword" class="col-sm-3 col-form-label d-md-block">密码：</label>
           	   <div class="col-sm-9 text-left">
           	   	  <span class="glyphicon glyphicon-pwd"></span>
           	   	  <input id="pwd" name="pwd" class="form-control" placeholder="" type="password">
           	   </div>
               
           </div>
           
           
          
           <div class="form-row row align-items-center">
           	  <div class="checkbox  col float-left">
                 <label  for="remember-me">
                   <input value="remember-me" name="remFlag" id="remFlag" onclick="remember();" type="checkbox"> 记住密码
                 </label>
              </div>
              <div class="col float-right">
              	<button class="btn btn-md btn-primary btn-block" type="submit">登录</button>
              </div>
               
           </div>
           <!--<p class="mt-5 mb-3 text-muted">© 2017-2018</p>-->
        </form>
        </div>


		<script src="<%=request.getContextPath()%>/resources/js/jquery.slim.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="<%=request.getContextPath()%>/resources/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	</body>
	<script type="text/javascript">
						function test(){
							var name = document.getElementById("username").value;
							var password = document.getElementById("pwd").value;
							
							if(name==null||name==""||name==undefined){
								alert("请输入账号！");
								return false;
							}
							if(password==null||password==""||password==undefined){
								alert("请输入密码！");
								return false;
							}
						
						}
						
						
					</script>
	<script type="text/javascript">
		$(document).ready(function(){
		    //记住密码功能
		    var str = getCookie("loginInfo");
		    str = str.substring(1,str.length-1);
		    var username = str.split(",")[0];
		    var password = str.split(",")[1];
		    //自动填充用户名和密码
		    $("#username").val(username);
		    $("#pwd").val(password);
		});
		
		//获取cookie
		function getCookie(cname) {
		    var name = cname + "=";
		    var ca = document.cookie.split(';');
		    for(var i=0; i<ca.length; i++) {
		        var c = ca[i];
		        while (c.charAt(0)==' ') c = c.substring(1);
		        if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
		    }
		    return "";
		}
		
		//记住密码功能
		function remember(){
		    var remFlag = $("input[type='checkbox']").is(":checked");
		    if(remFlag==true){ //如果选中设置remFlag为1
		        //cookie存用户名和密码,回显的是真实的用户名和密码,存在安全问题.
		        var conFlag = confirm("记录密码功能不宜在公共场所(如网吧等)使用,以防密码泄露.您确定要使用此功能吗?");
		        if(conFlag){ //确认标志
		            $("#remFlag").val("1");
		        }else{
		            $("input[type='checkbox']").removeAttr('checked');
		            $("#remFlag").val("");
		        }
		    }else{ //如果没选中设置remFlag为""
		        $("#remFlag").val("");
		    }
		}
	</script>
		<script type="text/javascript"> 
		   window.onload=function(){ 
				var action ='<%=request.getAttribute("result")%>';
				if(action.length!==4)
				{
						alert(action);
				}
			} 
		</script> 
		<script language="javascript">
        //防止页面后退
        history.pushState(null, null, document.URL);
        window.addEventListener('popstate', function () {
            history.pushState(null, null, document.URL);
        });
	</script>
</html>
